package com.eol.common.sequence;

import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * SequenceGen
 *
 * @author liulinhui
 * @email 1249055292@qq.com
 * @date 2020/6/1 21:37
 */
@Component
public class SequenceGen {

    @Resource
    private Sequence sequence;

    private static final String userIdPrefix = "u_"; //用户
    private static final String newsIdPrefix = "ZX_"; //资讯
    private static final String mediaPrefix = "mlM_"; //图片视频
    private static final String courseTypePrefix = "CT_"; //课程类型
    private static final String coursePrefix = "KC_"; //课程前缀


    public String genUserId() {
        return userIdPrefix + sequence.nextString();
    }

    public String genNewsId() {
        return newsIdPrefix + sequence.nextString();
    }

    public String genMediaId() {
        return mediaPrefix + RandomStringUtils.randomNumeric(10);
    }

    public String genCourseTypeId() {
        return courseTypePrefix + sequence.nextString();
    }

    public String genCourseId() {
        return coursePrefix + sequence.nextString();
    }

}
